﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.IO;
using clsLib_ActiveDevice;
using Fingu.ATF.Testing;


namespace Test
{
    public partial class Form1 : Form
    {
        TMR045 tmr045 = new TMR045();

        private bool CheckFileIsExist(string filePath)
        {
            if (File.Exists(filePath))
            {
                SetFileName(filePath);

                return true;
            }
            else
            {
                return false;
            }
        }
        private string FileName = "";
        private string GetFileName()
        {
            if (FileName != "")
            {
                return FileName;
            }
            else
            {
                return "";
            }

        }
        private void SetFileName(string arg)
        {
            this.FileName = arg;
        }

        public Form1()
        {
            InitializeComponent();            
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string prgName = "UI_TMR045.dll";
            string filePath = System.IO.Directory.GetCurrentDirectory() + "\\" + prgName;

            if (CheckFileIsExist(filePath))
            {
                Assembly assembly1 = Assembly.Load(GetFileName());
                Assembly assembly2 = Assembly.LoadFrom(GetFileName());
            } 
        }
        private void button2_Click(object sender, EventArgs e)
        {
            Assembly SampleAssembly;
            // Instantiate a target object.
            Int32 Integer1 = new Int32();
            Type Type1;
            // Set the Type instance to the target class type.
            Type1 = Integer1.GetType();
            // Instantiate an Assembly class to the assembly housing the Integer type.  
            SampleAssembly = Assembly.GetAssembly(Integer1.GetType());
            // Write the display name of assembly including base name and version.
            Console.WriteLine("FullName=" + SampleAssembly.FullName);


            
 

        }
        private void button3_Click(object sender, EventArgs e)
        {            
            //tmr045.SetListBox(listBox1);
            tmr045.SetRichTextBox(richTextBox1);
            tmr045.sendCommand("OPEN_CHANNEL1_PA");
            tmr045.receiveCommand();
        }

        private void btnExport_Click(object sender, EventArgs e)
        {
            frmExport _frmExport = new frmExport();
            _frmExport.Show();
        }
    }
}
